package com.neusoft.zqygbc.neusoft_wenda.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.neusoft.zqygbc.neusoft_wenda.R;
import com.neusoft.zqygbc.neusoft_wenda.activity.QuestionContentActivity;
import com.neusoft.zqygbc.neusoft_wenda.base.RecyclerViewAdapter;
import com.neusoft.zqygbc.neusoft_wenda.javeBean.QuestionEntity;

import java.util.List;

/**
 * Created by Shinelon on 2017/5/19.
 */

public class CreateQuestionAdapter extends RecyclerViewAdapter<CreateQuestionAdapter.ViewHolder> {


    public CreateQuestionAdapter(Context context, List data, int layoutResource) {
        super(context, data, layoutResource);
    }

    @Override
    public void onBindViewHolder(final CreateQuestionAdapter.ViewHolder holder, final int position) {
        final QuestionEntity entity = (QuestionEntity) data.get(position);
        holder.mycreate_date.setText(entity.getCreatetime());
        switch (entity.getTid()) {

            case "1":
                holder.mycreate_type.setText("Android");
                break;

            case "2":
                holder.mycreate_type.setText("PHP");
                break;

            case "3":
                holder.mycreate_type.setText("Web");
                break;

            case "4":
                holder.mycreate_type.setText("iOS");
                break;

            default:
                break;
        }
        holder.mycreate_description.setText(entity.getDescription());
        holder.mycreate_container.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, QuestionContentActivity.class);
                intent.putExtra("qid", entity.getQid());
                intent.putExtra("question_uid", entity.getUid());
                context.startActivity(intent);
            }
        });

    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        LinearLayout mycreate_container;
        TextView mycreate_date,mycreate_type,mycreate_description;



        public ViewHolder(View itemView) {
            super(itemView);
            mycreate_container = (LinearLayout) itemView.findViewById(R.id.mycreate_container);
            mycreate_date = (TextView) itemView.findViewById(R.id.mycreate_date);
            mycreate_type = (TextView) itemView.findViewById(R.id.mycreate_type);
            mycreate_description = (TextView) itemView.findViewById(R.id.mycreate_description);

        }
    }






}

